/**
 * Description: 字符串转数字
 * File: string_to_number.cpp |Time: 2022-05-09 13:33
 */

#include <iostream>
#include <sstream>

using namespace std;

int main(int argc, const char *argv[])
{
    string str = "-1234.5678";
    int a = 100;
    double num = 0;
    // 先实例化一个字符串转数字的对象
    istringstream str2num(str);
    // 将转换后的数字写入
    str2num >> num;
    cout << "num is: " << num << " num+100" << num + a << endl;

    return 0;
}

